<!DOCTYPE html>
<!--[if IE 8]> <html  class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html  class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">

    <link rel="stylesheet" type="text/css" href="${jpath}/assets/public/ice/css/bootstrap/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="${jpath}/assets/public/ice/css/themes/theme.css"/>
</head>
<body>
<div class="container-fluid " style="height: 400px;overflow: auto;" >
    <div class="col-xs-12">
        <div id="ztree" class="ztree"></div>
    </div>
</div>

<div class="row navbar-fixed-bottom">
    <div class="col-xs-12 text-center">
        <input type="button" class="btn btn-sm btn-info btn-sm" value="确定" onclick="doSave()"/>
        <input type="button" class="btn btn-cancle  btn-sm" value="关闭" onclick=" top.$.bootbox.hideAll();"/>
    </div>
</div>
</body>


<!--[if !IE]> -->
<script src="${jpath}/assets/public/jquery/jquery2x.js" type="text/javascript"></script>
<!-- <![endif]-->
<!--[if IE]>
<script src="${jpath}/assets/public/jquery/jquery1x.js" type="text/javascript"></script>
<![endif]-->

<!-- ztree-->
<link href="${jpath}/assets/public/plugins/jquery-ztree/3.5.12/css/zTreeStyle/zTreeStyle.min.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript"
        src="${jpath}/assets/public/plugins/jquery-ztree/3.5.12/js/jquery.ztree.all-3.5.min.js"></script>
<script src="${jpath}/assets/public/component.js" type="text/javascript"></script>
<script type="text/javascript">

    //ztree
    var setting = {

        callback: {
            onDblClick:function(event, treeId, treeNode){
                doInfo(treeNode.id,treeNode.name)
            }
        },
        async: {
            dataType: 'jsonp',
            type: "get",
            enable: true,
            url: "${rpath}/area/view/treeList"
        }
    };

    function doInfo(id,name){
        var idField = getQueryString('idField');
        var textField = getQueryString('textField');
        var fn = getQueryString('fn');
        if (typeof fn == 'function') {
            eval("top." + fn + "(" + id + "," + name + ")");
        } else {
            var contentFrame=getCurrentFrame();
            if(contentFrame){
                var contentFrameDoc=contentFrame.document;
                $("#" + idField, contentFrameDoc).val(id);
                $("#" + textField, contentFrameDoc).val(name);
            }
            else{
                $("#" + idField, top.window.document).val(id);
                $("#" + textField, top.window.document).val(name);
            }

            top.$.bootbox.hideAll();
        }
    }

     function doSave(){
         var treeObj = $.fn.zTree.getZTreeObj("ztree");
         var nodes = treeObj.getSelectedNodes();//获得选中节点数据集合
         if(nodes.length>0){
             doInfo(nodes[0].id,nodes[0].name);
         }
     else{
             top.$.bootbox.hideAll();
         }
     }

    $(function () {
        $.fn.zTree.init($("#ztree"), setting, null);
    })
</script>
</html>